﻿@model IEnumerable<CmsAdminFileItem>

@helper FileClass(string ext){
    string.Format("file ext_{0}", ext);    
}
@functions{  
string CreateRel(string rootDirectory, string name, int entityId){
    return !string.IsNullOrWhiteSpace(rootDirectory) ?
            string.Format("{0}/{1}", rootDirectory, name):
            entityId.ToString();
}
string CreateRev(string rootDirectory, string name, string id)
{
    return !string.IsNullOrWhiteSpace(rootDirectory) ?
            string.Format("{0}/{1}", rootDirectory, name) :
            id;
}
}
<ul class="jqueryFileTree" style="display:block">
    @foreach(var item in Model.Where(x=>x.IsDisabled == false))
    {
        if (!item.IsFile)
        {
            <li class="directory collapsed">
                <a href="#" rel="@CreateRel(item.RootDirectory, item.Name, item.EntityId)" rev="@CreateRev(item.RootDirectory, item.Name, item.Id)">@item.Name</a>
                @if (item.NestedFileItems != null)
                {
                    @Html.Partial("FileSystemViewItem", item.NestedFileItems)
                } 
            </li>
        }
        else
        {
            <li class="@item.Ext">
                <a class="fileViewItem" href="#" rel="@CreateRel(item.RootDirectory, item.Name, item.EntityId)" rev="@CreateRev(item.RootDirectory, item.Name, item.Id)">@item.Name</a>  
                @if (item.NestedFileItems != null)
                {
                    @Html.Partial("FileSystemViewItem", item.NestedFileItems)
                } 
            </li>      
        }
    }
</ul>